home *** CD-ROM | disk | FTP | other *** search
- Path: risky.ecs.umass.edu!usenet
- From: jvinson@cheux.ecs.umass.edu (Jack Vinson)
- Newsgroups: comp.lang.c++
- Subject: template instantiation (was passing references to containers?)
- Date: 13 Mar 1996 15:13:31 -0500
- Organization: University of Massachusetts
- Message-ID: <wopwaglpjo.fsf_-_@cheux.ecs.umass.edu>
- References: <wozq9lc29c.fsf@cheux.ecs.umass.edu>
- NNTP-Posting-Host: cheux.ecs.umass.edu
- To: jvinson@cheux.ecs.umass.edu (Jack Vinson)
- X-Newsreader: September Gnus v0.51/Emacs 19.30
-
- >>>>> "JV" == Jack Vinson <jvinson@cheux.ecs.umass.edu> writes:
-
- JV> I have a basic array template that does bound-checking in the [] operator.
- JV> I want to pass these arrays around by reference to reduce the amount of
- JV> creating and destroying going on.
-
- JV> However, in SOME cases, the compiler complains when I try to access
- JV> elements of the given array... [snip]
-
- I found the error. This has to do with the fact that a template needs to
- be instantiated in each file where it is used. In general this doesn't
- bite people, but when I want to pass my container around it may not get
- instantiated elsewhere in the file.
-
- From reading this group, it appears that the solutions is to add a dummy
- function to each file (or to a common .h file) with variables of the
- appropriate types.
-
- i.e.
-
- void foo()
- {
- array<class1> c1;
- array<class2> c2;
- }
-
- will create array templates for class1 and class2 so they can be used in
- the code in the given file.
-
- Where can I read up on the rationale for this.
-
- --
- Jack Vinson jvinson@cheux.ecs.umass.edu
- "I Spit on Your Grave" -- double feature at the drive-in as seen
- "I Thumb Through Your Magazines" from the Qwik-E mart
-
-